jvc.ui.accordion=new jvc_ui_accordion();
function jvc_ui_accordion(){	
	var parentObject;
	var lastSelectLi;
	this.set=function(obj){
		parentObject=obj;
		var index=0;	
		for(var i=0;i<obj.childNodes.length;i++){
			//内容
			var e=obj.childNodes[i];
			if(!e.tagName)continue;
			var me=this;
			index++;
			if(index % 2 ==1){
					jvc.attachEvent(e,"click",function(){me.select(this)});
					e.className="accordion_header";
				}else {				
					e.className="accordion_content";
					for(var j=0;j<e.childNodes.length;j++){
						var esub=e.childNodes[j];
						if(!esub.tagName)continue;
						jvc.attachEvent(esub,"click",function(){me.selectLi(this)});
						if(esub.getAttribute("selected")){this.selectLi(esub);}
						else esub.className="accordion_content_out";	
						
					}
				}
			if(e.getAttribute("selected")){this.select(e);}
		}
		jvc.attachEvent(parentObject,"selectstart",function(){return false;});
	}

	this.selectLi=function(div){
		if(lastSelectLi)lastSelectLi.className="accordion_content_out";
		div.className="accordion_content_select";	
		lastSelectLi=div;	
	}	
	
	this.select=function(div){
		var isShow=false;
		var index=0;
		for(var i=0;i<parentObject.childNodes.length;i++){
			var e=parentObject.childNodes[i];
			if(!e.tagName)continue;
			index++;
			if(index % 2 ==0){e.style.display="none";} 
			if(isShow){
				isShow=false;e.style.display="block";
			}
			if(div==e)isShow=true;	
		}
	}

} 
